<?php

/**
 * This is the model class for table "tbl_empgroup".
 *
 * The followings are the available columns in table 'tbl_empgroup':
 * @property integer $groupid
 * @property string $groupdesc
 */
class Empgroup extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Empgroup the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_empgroup';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('groupdesc', 'required'),
			array('groupdesc', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('groupid, groupdesc', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'groupid' => 'Groupid',
			'groupdesc' => 'Groupdesc',
		);
	}

	public static function getList(){
            return CHtml::listData(self::model()->findAll(), 'groupid', 'groupdesc');
        }
        public static function getText($id){
            $data=self::model()->findByPk($id);
            if($data!=NULL) return $data->groupdesc;
            return '';
        }
}